/**
 * Created by 坤 on 2017/2/25.
 */
$(function(){
    if($(".create_helisMember .create_helisMemberInfo").children().length==0){
        $(".ch_addImage").css("display","block");
    }else{
        $(".ch_addImage").css("display","none");
    }

    var myDate = new Date();
    myDate.getYear();
    //获取当前年份(2位)
    myDate.getMonth();
    //获取当前月份(0-11,0代表1月)
    myDate.getDate();
    //获取当前日(1-31)
    myDate.getDay();
    //获取当前时间(从1970.1.1开始的毫秒数)
    myDate.getHours();
    //获取当前小时数(0-23)
    myDate.getMinutes();
    //获取当前分钟数(0-59)
    myDate.getSeconds();
    //获取当前秒数(0-59)
    myDate.getMilliseconds();
    //获取日期与时间
    myDate.toLocaleString( );

    var mytime=myDate.toLocaleTimeString();

    var keqianzhunbeiLayer='<div class="eb_content_ListInfo">'+
                                '<div class="eb_top_title clearfix">'+
                                    '<div class="eb_top_left fl">'+
                                       '<p>课前准备</p>'+
                                    '</div>'+
                                     '<div class="eb_top_right fl">'+
                                        '<span>上课时间：'+myDate.toLocaleDateString()+'&nbsp;'+mytime+'</span>'+
                                     '</div>'+
                                '</div>'+
                                 '<div class="eb_middle">'+
                                     '<textarea class="eb_middle_title" placeholder="内容："></textarea>'+
                                 '</div>'+
                                '<div class="btn_queen">确定</div>'+
                            '</div>';

    var jiatingzuoyeLayer='<div class="eb_content_ListInfo">'+
                                '<div class="eb_top_title clearfix">'+
                                    '<div class="eb_top_left fl">'+
                                       '<p>作业准备</p>'+
                                    '</div>'+
                                    '<div class="eb_top_right fl">'+
                                       '<span>上交时间：'+myDate.toLocaleDateString()+'&nbsp;'+mytime+'</span>'+
                                    '</div>'+
                                '</div>'+
                                '<div class="eb_middle">'+
                                   '<textarea class="eb_middle_title" placeholder="内容："></textarea>'+
                                '</div>'+
                                '<div class="btn_queen">确定</div>'+
                            '</div>';

    $("#house_zuoye .titles_right_save").click(function(){
        layer.open({
            title:'添加课前准备',
            className:'keqianzhunbei',
            content:keqianzhunbeiLayer
        })
    })
    $("#house_zuoye .hz_content_title_choose li").click(function(){

        $("#house_zuoye .hz_content .tabBox .tabList").removeClass("xianshi_1");
        $("#house_zuoye  .hz_content_info .tabBox").children().eq($(this).index()).addClass("xianshi_1");
        if($(this).index()==0){
            $("#house_zuoye  .hz_content_title .bottom-jiantou").animate({
                left:"0rem"
            },1000);
            $("#house_zuoye .titles_right_save").click(function(){
                    layer.open({
                        title:'添加课前准备',
                        className:'keqianzhunbei',
                        content:keqianzhunbeiLayer
                    })
            })
        }
        if($(this).index()==1){
            $("#house_zuoye  .hz_content_title .bottom-jiantou").animate({
                left:"7rem"
            },1000);
            $("#house_zuoye .titles_right_save").click(function(){
                layer.open({
                    title:'添加家庭作业',
                    className:'jiatingzuoye',
                    content:jiatingzuoyeLayer
                })
            })
        }
    });


   /*跳转好友列表页面*/
   $(".ch_addImage").click(function(){
       self.location='Manage_person.html';
   });


    /*科目取值*/
    var kemu="";
    $(".cd_List_kemu").click(function(){
        var th=$(this);
        layer.open({
            title: [
                '科目选择',
                'background-color: #FF4351; color:#fff;'
            ]
            ,className:'kemuName'
            ,content:
            '<div class="kemu_layer">' +
                '<div class="kemu_layer_content">'+
                    '<ul class="clearfix">' +
                      '<li class="fl">语文</li>'+
                      '<li class="fl">数学</li>'+
                      '<li class="fl">英语</li>'+
                      '<li class="fl">体育</li>'+
                      '<li class="fl">历史</li>'+
                      '<li class="fl">美术</li>'+
                    '</ul>'+
                    '<input type="text" class="teacherName" value="" placeholder="请输入教师姓名"/>'+
                '</div>'+
                '<div class="kemu_btn">' +
                    '确定'+
                '</div>'+
            '</div>'
           ,success:function(elem,index){
                var teacherName;
                $(".kemu_layer .kemu_layer_content ul li").click(function(){
                    $(".kemu_layer .kemu_layer_content ul li").css("border","0.05rem solid #CFCFCF")
                    $(this).css("border","0.05rem solid red");
                    kemu=$(this).text();
                });
                $(".kemu_btn").click(function(){
                    teacherName=$(".teacherName").val();
                    if(kemu==""||$(".teacherName").val().length==0){
                        layer.open({
                            content: '请选择科目和填写教师名称'
                            ,skin: 'msg'
                            ,time: 2 //2秒后自动关闭
                        });
                    }else{
                        $(th).children().children("label").html(kemu);
                        $(th).children(".teacher_name").html(teacherName);
                        kemu="";
                        layer.close(index);
                    }
                })
           }
        });
    });
    /*科目取值*/
    $(".cd_List_xuehao").click(function(){
        var th=$(this);
        layer.open({
            title: [
                '学号选择',
                'background-color: #FF4351; color:#fff;'
            ]
            ,className:'xuehaoName'
            ,content:
            '<div class="xuehao_layer">' +
            '<div class="xuehao_layer_content">'+
            '<input type="text" class="xuehaoNumber" value="" placeholder="请输入学号"/>'+
            '<input type="text" class="xueshengName" value="" placeholder="请输入学生姓名"/>'+
            '</div>'+
            '<div class="xuehao_btn">' +
            '确定'+
            '</div>'+
            '</div>'
            ,success:function(elem,index){
                var xueshengName;
                var xuehaoNumber;
                $(".xuehao_btn").click(function(){
                    xueshengName=$(".xueshengName").val();
                    xuehaoNumber=$(".xuehaoNumber").val();
                    if($(".xuehaoNumber").val().length==0||$(".xueshengName").val().length==0){
                        layer.open({
                            content: '请填写学号与姓名'
                            ,skin: 'msg'
                            ,time: 2 //2秒后自动关闭
                        });
                    }else{
                        $(th).children().children("label").html(xuehaoNumber);
                        $(th).children(".student_name").html(xueshengName);
                        layer.close(index);
                    }
                })
            }
        });
    });
});